<template>
  <div class="rewardList">
    <top :text="''"></top>
    <div class="rewardListTitle">
      <span style="margin-right: 40px;" :class="{active:isActive}" @click="set(true)">奖励列表</span>
      <span :class="{active:!isActive}" @click="set(false)">待投资</span>
    </div>
    <div class="inviteNumber" v-if="isActive">
      <span style="color: #fea620">投资人数:{{list.people||0}}</span>
      <span style="color: #ff1010;margin-left:10px">奖励金额:{{list.moneys||0}}</span>
    </div>
    <div class="inviteNumber" v-else>
      <span style="color: #fea620">待投资人数:{{list.people||0}}</span>
    </div>
    <div style="padding:0px 10px;">
      <div v-if="isActive">
        <div class="inviteBox" v-for="ls in list.lists">
          <div style="display: flex;font-size: 16px;height: 25px;line-height: 25px;">
            <div style="flex: 1.6">投资时间</div>
            <div style="flex: 1;">手机号</div>
            <div style="flex: 1;text-align: right">邀请级别</div>
          </div>
          <div style="display: flex;color: #333;height: 25px;line-height: 25px;" class="phoneSty">
            <div style="flex: 1.6">{{ls.created.split("T")[0]}}</div>
            <div style="flex: 1;">{{ls.username|formatPhone}}</div>
            <div style="flex: 1;text-align: right">
              <span style="background: -webkit-gradient(linear, left top, right top, from(#fed22b), to(#fea50e));color: #fff;padding: 0px 20px;border-radius: 20px;">{{ls.stage}}</span>
            </div>
          </div>
          <div style="display: flex;color: #999;font-size: 12px;">
            <div style="flex: 1.6">返点</div>
            <div style="flex: 1;">金额</div>
            <div style="flex: 1;text-align: right">类型</div>
          </div>
          <div style="display: flex;font-size: 16px;">
            <div style="flex: 1.6;color: #ff1010;font-size: 18px;">{{ls.rate}}</div>
            <div style="flex: 1;color: #ff1010;font-size: 18px;">{{ls.payAmount}}</div>
            <div style="flex: 1;text-align: right">{{ls.kind}}</div>
          </div>
        </div>
      </div>
      <div v-else>
        <div class="toBeInvested" v-for="ls in list.lists">
          <div style="display: flex">
            <div style="flex: 1.6">注册时间</div>
            <div style="flex: 1">手机号</div>
            <div style="flex: 1;text-align: right;">邀请级别</div>
          </div>
          <div style="display: flex;font-size: 12px;color: #666;height: 25px;line-height: 25px;">
            <div style="flex: 1.6">{{ls.created.split("T")[0]}}</div>
            <div style="flex: 1">{{ls.userid|formatPhone}}</div>
            <div style="flex: 1;text-align: right;">
              <span style="background: -webkit-gradient(linear, left top, right top, from(#fed22b), to(#fea50e));color: #fff;padding: 0px 20px;border-radius: 20px;">{{ls.stage}}</span>
            </div>
          </div>
        </div>
      </div>
      <div style="text-align: center;" v-if="list.lists.length==0">
        <img src="../../assets/noData.png" alt="" width="200">
      </div>
    </div>
  </div>
  </div>
</template>
<script>
  import util from '../../service/util.js'
  import Top from '../../components/common/top.vue'
  export default {
    components: {
      Top,
    },
    data() {
      return {
        isActive: true,
        username: "",
        list: [],
      }
    },
    mounted() {
      this.username = util.getItem("login.username");
      if(!this.username){
          this.$router.push({path:'/main/home'})
      }
      this.getData();
    },
    methods: {
      set(status) {
        this.isActive = status;
        this.getData();
      },
      getData() {
        var url = "";
        if (this.isActive) {
          url = "/invite/invites?username=" + this.username
        } else {
          url = "/invite/invited?username=" + this.username
        }
        this.http.get(url).then(res => {
          if (res.status == 200) {
            this.list = res.data.body;
          }
        })
      }
    }
  }
</script>
<style lang="less" scoped>
  .rewardListTitle {
    height: 40px;
    line-height: 40px;
    text-align: center;
    z-index: 9999999;
    position: fixed;
    left: 30%;
  }

  .active {
    color: #fea620;
    border-bottom: 1px solid #fea620;
    display: inline-block;
    height: 40px;
    line-height: 40px;
  }

  .inviteNumber {
    height: 40px;
    font-size: 12px;
    text-align: right;
    margin-right: 15px;
    line-height: 40px;
    padding-top: 45px;
  }

  .phoneSty {
    font-size: 12px;
  }

  .inviteBox {
    height: 100px;
    border: 1px solid #efefef;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0px 2px 1px 1px #efefef;
    margin-bottom: 10px;
  }

  .toBeInvested {
    height: 55px;
    box-shadow: 0px 2px 1px 1px #efefef;
    border: 1px solid #efefef;
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 10px;
  }
</style>